package com.example.module_home.adapter

import android.view.ViewGroup
import android.widget.ImageView
import androidx.recyclerview.widget.RecyclerView
import com.example.lib_common.view.entity.BannerEntity
import com.example.lib_image.glide.glide.GlideImgLoader
import com.youth.banner.adapter.BannerAdapter

class HomeBannerAdapter(data:List<BannerEntity>):BannerAdapter<BannerEntity,HomeBannerAdapter.BannerViewHolder>(data){
    inner class BannerViewHolder(val imageView: ImageView):RecyclerView.ViewHolder(imageView)

    override fun onCreateHolder(parent: ViewGroup?, viewType: Int): BannerViewHolder {
        val imageView=ImageView(parent!!.context)
        imageView.layoutParams=ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT)
        imageView.scaleType=ImageView.ScaleType.CENTER_CROP
        return BannerViewHolder(imageView)
    }

    override fun onBindView(
        holder: BannerViewHolder?,
        data: BannerEntity?,
        position: Int,
        size: Int,
    ) {
        GlideImgLoader.loadResImage(holder!!.imageView,data!!.resId,holder!!.imageView)
    }


}